package com.android.fragmentdemo.adapters
import android.util.Log
import com.android.fragmentdemo.R
import com.android.fragmentdemo.databinding.RvVerticalItemLayoutBinding
import com.hengfoxwolf.commonbase.base.adapter.BaseRvAdapter

class CustomVerticalLayoutManagerAdapter : BaseRvAdapter<String, RvVerticalItemLayoutBinding>() {

    private var doSpecial = false

    override fun getLayoutId(): Int = R.layout.rv_vertical_item_layout

    override fun bindData(holder: ViewHolder, dataItem: String, position: Int) {
        holder.binding.rvVerticalTv.text = dataItem
        if (doSpecial) {
            if (position == 0) {
                Log.d(TAG, "listenerWithBinding---position---0")
                //holder.binding.rvVerticalTv.elevation = 3F
                /*holder.binding.rvVerticalTv.post {
                    holder.binding.rvVerticalTv.animate().*//*withLayer().*//*scaleX(1.05F).scaleY(1.05F).setDuration(200).start()
                    //holder.binding.rvVerticalTv.bringToFront()
                }*/

                holder.binding.flVerticalTv.animate()./*withLayer().*/scaleX(1.05F).scaleY(1.25F).setDuration(200).start()

                //holder.binding.rvVerticalTv.animate()./*withLayer().*/scaleX(1.05F).scaleY(1.05F).setDuration(200).start()
            } else {
                //holder.binding.rvVerticalTv.elevation = 1F
                /*holder.binding.rvVerticalTv.post {
                    holder.binding.rvVerticalTv.animate().scaleX(1.0F).scaleY(1.0F).setDuration(200).start()
                }*/

                holder.binding.flVerticalTv.animate().scaleX(1.0F).scaleY(1.0F).setDuration(200).start()

                //holder.binding.rvVerticalTv.animate().scaleX(1.0F).scaleY(1.0F).setDuration(200).start()
            }
        }
        Log.d(TAG, "listenerWithBinding---position---${position}")
    }

    override fun listenerWithBinding(binding: RvVerticalItemLayoutBinding) {
        super.listenerWithBinding(binding)
        Log.d(TAG,"listenerWithBinding---i")
    }

    fun updateSpecial(doSpecial: Boolean) {
        this.doSpecial = doSpecial
    }

    companion object {
        const val TAG = "CustomVerticalLayoutManagerAdapter"
    }
}